package com.jy.project.mapper;

import com.jy.project.domain.Dict;
import com.jy.project.dto.DictQueryDTO;
import com.jy.project.vo.DictVO;
import org.apache.commons.lang3.StringUtils;
import tk.mybatis.mapper.common.Mapper;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

public interface DictMapper extends Mapper<Dict> {

    /**
     * 部门信息查询
     * */
    List<DictVO> listDictVO(DictQueryDTO queryDTO);

    default  List<Dict>  listParentDictByName(Dict dict){
        Example example=new Example(Dict.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.andEqualTo("name",dict.getName())
                .andEqualTo("isDelete",0)
                .andEqualTo("dictType",dict.getDictType());
        //说明是一级目录
        if (StringUtils.isNotEmpty(dict.getParentNo())){
            criteria.andEqualTo("parentNo",dict.getParentNo());
        }
        List<Dict> dicts = this.selectByExample(example);
        return  dicts;
    }


}
